package com.jnu.hc.jnuhcdoccms.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jnu.hc.jnuhcdoccms.dto.ROrderListRequestDto;
import com.jnu.hc.jnuhcdoccms.dto.ROrderListResponseDto;
import com.jnu.hc.jnuhcdoccms.dto.ResponseObject;
import com.jnu.hc.jnuhcusercms.mapper.OrdersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ROredersServiceImpl implements ROredersService {
    @Autowired
    OrdersMapper ordersMapper;

    @Override
    public ResponseObject rorderList(ROrderListRequestDto rOrderListRequestDto){
        PageHelper.startPage(rOrderListRequestDto.getPageNumber(), rOrderListRequestDto.getPageSize());
        List<ROrderListResponseDto> rOrderListResponseDtoList =ordersMapper.rorderList(rOrderListRequestDto);
        PageInfo<ROrderListResponseDto> pageInfo =new PageInfo<>(rOrderListResponseDtoList);
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("list", rOrderListResponseDtoList); // 数据列表
        resultMap.put("pageInfo", pageInfo);              // 分页信息


        return  new ResponseObject(200,"订单查询成功",resultMap);
    }
}
